package com.xiaotu.spider.maoyan.pipeline;


import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.xiaotu.common.model.MaoYanMovieScoreModel;
import com.xiaotu.common.util.Constants;
import com.xiaotu.common.util.DataRedisKeyUtils;
import com.xiaotu.spider.APipeline;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
/***
 * 
 * @author Administrator
 *
 */
@Component("MaoYanMovieScorePipeline")
@Scope("prototype")
public class MaoYanMovieScorePipeline extends APipeline{

	@Override
	protected void doProcess(ResultItems resultItems, Task task) {
		MaoYanMovieScoreModel maoYanMovieScoreModel = resultItems.get(MaoYanMovieScoreModel.class.getName());
		if (maoYanMovieScoreModel == null)
            return;
		String key = DataRedisKeyUtils.getKey(Constants.DataRedisKey.MAOYAN_MOVIE_SCORE_YYYYMMDD);
        	cacheHandler.hSet(key, maoYanMovieScoreModel.getId(), maoYanMovieScoreModel);
        	cacheHandler.setCacheTimeout(key);
	}
}
